<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.test.entity.UserInfo"%>
<%@page import="com.test.entity.News"%>
<%@ include file="cfmt/tldImport.jsp"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@page import="com.test.entity.CardType"%>
<%@page
	import="org.springframework.context.support.ClassPathXmlApplicationContext"%>
<%@page import="com.test.dao.OrderDetailDAO"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>游戏点卡销售平台</title>
<script language="javascript" src="js/switch.js"></script>
<link href="css/common.css" rel="stylesheet" type="text/css" />
<link href="css/index.css" rel="stylesheet" type="text/css" />
<script>
	function into() {
		form1.action = "news!keyWord.action";
		form1.submit();
	}
</script>
</head>
<body>
	<div id="top">
		<div class="logo">
			&nbsp;<img src="images/logo.gif" />
		</div>
		<div class="tmenu">


			<c:if test="${userInfo!=null}">
				<span>你好，${userInfo.userId}</span>
				<span>|</span>
				<span><a href="cart.jsp">我的购物车</a></span>
				<span>|</span>
				<span><a href="userm.jsp">用户中心</a></span>
				<span>|</span>
				<span><a href="loginout.jsp">退出</a></span>
		</div>
		</c:if>
		<c:if test="${userInfo==null}">
			<span><a href="reg.jsp">注册</a></span>
			<span>|</span>
			<span><a href="login.jsp">登录</a></span>
	</div>
	</c:if>
	</div>



	<div id="main" style="display:block;">
		<div class="main_left">
			<div class="catalog">
				<div class="catalogtitle">卡&nbsp;片&nbsp;分&nbsp;类</div>
				<div class="catalogcontent">
					<ul>
						<c:forEach var="card" items="${CardType}" end="6">
							<li><a href="index!Catalog.action?cid=${card.id}">${card.cardTypeName}...${card.cardPrice}</a></li>
						</c:forEach>
					</ul>
				</div>
			</div>
		</div>
		<div class="main_right">
			<div id="menu">
				<div class="lmenu">
					<img src="images/menuleft.gif" />
				</div>
				<form action="index!keyWord.action" name="form1" method="post">
					<div class="cmenu">
						<span style="float:left;">请输入卡片关键字</span> <span class="sl"></span>
						<span class="sc"><input type="text" class="search"
							name="keyWord" value="" /></span> <span class="sr" onclick="into()"></span>
					</div>
				</form>
				<div class="rmenu">
					<img src="images/menuright.gif" />
				</div>
			</div>

			<div id="sysfun">
				<!--最新公告-->
				<div class="noticet">最新公告</div>
				<div class="noticec">

					<ul>
						<c:forEach var="ns" items="${nlist}">
							<li><a title="${ns.title}" href="news!NewsDetail.action?curpage1=1">
									<label>${ns.title}</label>
							</a></li>
						</c:forEach>
					</ul>
					<ul>
						<script>
							var _label = document.getElementsByTagName("label");
							for ( var i = 0; i < _label.length; i++) {
								var temp = _label[i].innerHTML.substring(0, 9)
										+ "...";
								_label[i].innerHTML = temp;
							}
						</script>
					</ul>
					<a href="news!NewsDetail.action?curpage1=1" class="more">更多>></a>
					<!--销售排行-->
					<div class="saleOrder">
						<br />
						<h4>销售排行</h4>
						<!-- 请教同学的 -->
						<%
							ApplicationContext ctx = new ClassPathXmlApplicationContext(
									"applicationContext.xml");
							OrderDetailDAO dao = (OrderDetailDAO) ctx.getBean("orderDetailDAO");
							List<Object[]> list = dao.queryBySeleQuantity();
							for (Object[] objs : list) {
								CardType ct = (CardType) objs[0];
								long quantity = (Long) objs[1];
						%>
						<li><a href="#<%=ct.getId()%>"><%=ct.getCardTypeName()%>.<%=quantity%></a></li>
						<%
							}
						%>
					</div>
				</div>

			</div>


			<!--广告图片轮换-->
			<div id="adv">
				<div class="album">
					<div id="picList">
						<ul>
							<li><a href="#" target="_blank"><img
									src="images/adv/01.jpg" /></a></li>
							<li><a href="#" target="_blank"><img
									src="images/adv/02.jpg" /></a></li>
							<li><a href="#" target="_blank"><img
									src="images/adv/03.jpg" /></a></li>
							<li><a href="#" target="_blank"><img
									src="images/adv/04.jpg" /></a></li>
						</ul>
					</div>
					<div id="picTitle">
						<ul>
							<li class="current">魔兽世界30元600点</li>
							<li class="normal">中华网游一卡通</li>
							<li class="normal">诛仙</li>
							<li class="normal">魔兽世界新手免费畅游卡</li>
						</ul>
					</div>
					<div id="picBtn">
						<ul>
							<li class="current"><img src="images/adv/btn_01.jpg" /></li>
							<li class="normal"><img src="images/adv/btn_02.jpg" /></li>
							<li class="normal"><img src="images/adv/btn_03.jpg" /></li>
							<li class="normal"><img src="images/adv/btn_04.jpg" /></li>
						</ul>
					</div>
				</div>
			</div>
			<!--图片轮换结束-->
		</div>
		<div id="pList">
			<div>
				<div class="psltitle">最新推荐商品</div>
				<div class="psrtitle">
					<a href="#" class="more">更多>></a>
				</div>
			</div>
			<!--推荐商品区-->
			<div class="pscontent">
				<c:forEach var="card" items="${CardType}" end="5">
					<div class="info">
						<img src="${card.cardImage}" class="cardImg" />
						<ul>
							<li>卡片名称:${card.cardTypeName}</li>
							<li>卡片面值:<span style="text-decoration:line-through;">${card.cardPrice}</span></li>
							<li>会员价:<span style="color:red;">￥</span><span
								class="memberPrice">${card.cardPrice*0.8}</span></li>
							<li>VIP价:<span style="color:red;">￥</span><span
								class="vipPrice">${card.cardPrice*0.7}</span></li>
							<li style="float:right;"><img src="images/add_cart.gif"
								onclick="window.location='shop!shop.action?method=add&cid=${card.id}';" /></li>
						</ul>
					</div>
				</c:forEach>
			</div>
		</div>
	</div>
	<div style="clear:both"></div>
	<div id="footer" style="display:block;">
		<div class="bmenu">
			<a href="#">免责条款</a>|<a href="#">隐私保护</a>|<a href="#">咨询热点</a>|<a
				href="#">联系我们</a>|<a href="#">公司简介</a>|<a href="#">批发方案</a>|<a
				href="#">配送方式</a>
		</div>
	</div>
</body>
</html>

